using System;
using THANHTUNGO.Portal.Components.UI;

namespace MONA.Modules.Marketing
{
    public enum MarketingPages
    {
        Service,
        AddEditService
    }

    public partial class Main : PortalModuleControl
    {
        private void loadChildControl()
        {
            string m_baseDir = "~/Modules/MONA.Marketing/";
            string pageQuery = "Page" + this.ModuleID;
            string pageName = Request.QueryString[pageQuery];

            MarketingPages page;
            if (pageName == null)
            {
                page = MarketingPages.Service;
            }
            else
            {
                page = (MarketingPages)Enum.Parse(typeof(MarketingPages), Request.QueryString[pageQuery], true);
            }

            string src = string.Format("{0}Controls/{1}.ascx", m_baseDir, page);
            
            /*
            if (src.IndexOf("/Mod_") >= 0)
                src = src.Replace("/Mod_", "/Mod/");
            if (src.IndexOf("/Admin_") >= 0)
                src = src.Replace("/Admin_", "/Admin/");
            if (src.IndexOf("/Help_") >= 0)
                src = src.Replace("/Help_", "/Help/");
            */

            YAFPage ctl = (YAFPage)this.LoadControl(src);
            ctl.ParentControl = this;
            ContentPane.Controls.Add(ctl);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.loadChildControl();
        }
    }
}